package com.zhl.hadoop.mapreduce.partition;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @program: demos
 * @description: 自己的类型序列化不适用java自带的序列化
 * @author: 刘振华
 * @create: 2020-10-28 10:57
 **/
public class PartitionMapper extends Mapper<LongWritable, Text,Text, NullWritable> {

	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		//第一种计数器
		Counter counter = context.getCounter("MAP_COUNTER", "p_counter");
		counter.increment(1L);
		context.write(value,NullWritable.get());
	}
}
